//创建异常类
class UsernameException extends Exception{

}
class PasswordException extends Exception {

}

//设置登录系统
class Login{
    private String username = "crane";
    private String password = "24170";

    public void login(String username,String password) throws UsernameException,PasswordException{
        if (!username.equals(this.username)) {

            throw new UsernameException();
        }
        if(!password.equals(this.password)){

            throw new PasswordException();
        }
        System.out.println("登录成功");
    }
}

public class Main {
    public static void main(String[] args) {
        Login lg = new Login();
        try {
            lg.login("night", "123456");
        } catch (UsernameException e){
            System.out.println("用户名错误");
        } catch (PasswordException e){
            System.out.println("密码错误");
        }
    }
}
